﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KnowlegeAssistant
{
    public enum PermissionType
    {
        all, 
        testall, testadd, testedit, testremove, testrun,
        statisticsall, statisticsmy, statisticsgroup, statisticsstudent,
        subjectall, subjectadd, subjectedit, subjectremove,
        themeall, themeadd, themeedit, themeremove,statisticsallstat,
        adminall,adminusers,adminroles,adminstudentsview,adminstudentsimport,
        adminteachersview,adminteachersimport
    }

    public class Permission
    {
        private int permission_id;
        private string name;
        private string description;
        private PermissionType type;

        public Permission(int permission_id, string description, string type)
        {
            this.permission_id = permission_id;
            this.name = type;
            this.description = description;
            GetPermissionType(type);
        }

        public int ID
        {
            get { return this.permission_id; }
        }

        public PermissionType Type
        {
            get { return this.type; }
        }

        public string Description
        {
            get { return this.description; }
        }

        public void GetPermissionType(string type)
        {
            switch (type)
            {
                case "all": this.type = PermissionType.all; break;
                case "test.all": this.type = PermissionType.testall; break;
                case "test.add": this.type = PermissionType.testadd; break;
                case "test.edit": this.type = PermissionType.testedit; break;
                case "test.remove": this.type = PermissionType.testremove; break;
                case "test.run": this.type = PermissionType.testrun; break;
                case "statistics.all": this.type = PermissionType.statisticsall; break;
                case "statistics.my": this.type = PermissionType.statisticsmy; break;
                case "statistics.group": this.type = PermissionType.statisticsgroup; break;
                case "statistics.student": this.type = PermissionType.statisticsstudent; break;
                case "subject.all": this.type = PermissionType.subjectall; break;
                case "subject.add": this.type = PermissionType.subjectadd; break;
                case "subject.edit": this.type = PermissionType.subjectedit; break;
                case "subject.remove": this.type = PermissionType.subjectremove; break;
                case "theme.all": this.type = PermissionType.themeall; break;
                case "theme.add": this.type = PermissionType.themeadd; break;
                case "theme.edit": this.type = PermissionType.themeedit; break;
                case "theme.remove": this.type = PermissionType.themeremove; break;
                case "statistics.allstat": this.type = PermissionType.statisticsallstat; break;
                case "admin.all": this.type = PermissionType.adminall; break;
                case "admin.users": this.type = PermissionType.adminusers; break;
                case "admin.roles": this.type = PermissionType.adminroles; break;
                case "admin.students.view": this.type = PermissionType.adminstudentsview; break;
                case "admin.students.import": this.type = PermissionType.adminstudentsimport; break;
                case "admin.teachers.view": this.type = PermissionType.adminteachersview; break;
                case "admin.teachers.import": this.type = PermissionType.adminteachersimport; break;
            }
        }
    }
}
